package net.codingme.boot.domain.mapper;

import java.util.List;

import net.codingme.boot.domain.Book;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
public interface BookMapper {
    /**
     * 注解方式配置映射
     *
     * @param author
     * @return
     * @Results 字段和属性映射关系
     * @Select 查询语句
     */
    @Results({
            @Result(property = "id", column = "ids"),
            @Result(property = "name", column = "name"),
            @Result(property = "author", column = "authors"),
            @Result(property = "createTime", column = "create_time")
    })
    @Select("select id as ids, author as authors, name, price, create_time, description from book where author = #{author}")
    List<Book> selectByAuthor(@Param("author") String author);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book
     *
     * @mbg.generated Thu Mar 07 10:26:35 GMT+08:00 2019
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book
     *
     * @mbg.generated Thu Mar 07 10:26:35 GMT+08:00 2019
     */
    int insert(Book record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book
     *
     * @mbg.generated Thu Mar 07 10:26:35 GMT+08:00 2019
     */
    Book selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book
     *
     * @mbg.generated Thu Mar 07 10:26:35 GMT+08:00 2019
     */
    List<Book> selectAll();

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table book
     *
     * @mbg.generated Thu Mar 07 10:26:35 GMT+08:00 2019
     */
    int updateByPrimaryKey(Book record);
}